package com.tianqi.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * 甲子旬数据
 *
 * @author zhangzedi
 * @date 2023/8/23 01:46
 **/
public enum JiaZiXunEnum {
	//首旬
	JIA_ZI(1, "甲子"),
	YI_CHOU(1, "乙丑"),
	BING_YIN(1, "丙寅"),
	DING_MAO(1, "丁卯"),
	WU_CHEN(1, "戊辰"),
	JI_SI(1, "己巳"),
	GENG_WU(1, "庚午"),
	XIN_WEI(1, "辛未"),
	REN_SHEN(1, "壬申"),
	GUI_YOU(1, "癸酉"),
	//二旬
	JIA_XU(2, "甲戌"),
	YI_HAI(2, "乙亥"),
	BING_ZI(2, "丙子"),
	DING_CHOU(2, "丁丑"),
	WU_YIN(2, "戊寅"),
	JI_MAO(2, "己卯"),
	GENG_CHEN(2, "庚辰"),
	XIN_SI(2, "辛巳"),
	REN_WU(2, "壬午"),
	GUI_WEI(2, "癸未"),
	//三旬
	JIA_SHEN(3, "甲申"),
	YI_YOU(3, "乙酉"),
	BING_XU(3, "丙戌"),
	DING_HAI(3, "丁亥"),
	WU_ZI(3, "戊子"),
	JI_CHOU(3, "己丑"),
	GENG_YIN(3, "庚寅"),
	XIN_MAO(3, "辛卯"),
	REN_CHEN(3, "壬辰"),
	GUI_SI(3, "癸巳"),

	//四旬
	JIA_WU(4, "甲午"),
	YI_WEI(4, "乙未"),
	BING_SHEN(4, "丙申"),
	DING_YOU(4, "丁酉"),
	WU_XU(4, "戊戌"),
	JI_HAI(4, "己亥"),
	GENG_ZI(4, "庚子"),
	XIN_CHOU(4, "辛丑"),
	REN_YIN(4, "壬寅"),
	GUI_MAO(4, "癸卯"),

	//五旬
	JIA_CHEN(5, "甲辰"),
	YI_SI(5, "乙巳"),
	BING_WU(5, "丙午"),
	DING_WEI(5, "丁未"),
	WU_SHEN(5, "戊申"),
	JI_YOU(5, "己酉"),
	GENG_XU(5, "庚戌"),
	XIN_HAI(5, "辛亥"),
	REN_ZI(5, "壬子"),
	GUI_CHOU(5, "癸丑"),


	//六旬
	JIA_YIN(6, "甲寅"),
	YI_MAO(6, "乙卯"),
	BING_CHEN(6, "丙辰"),
	DING_SI(6, "丁巳"),
	WU_WU(6, "戊午"),
	JI_WEI(6, "己未"),
	GENG_SHEN(6, "庚申"),
	XIN_YOU(6, "辛酉"),
	REN_XU(6, "壬戌"),
	GUI_HAI(6, "癸亥");

	/**
	 * 旬下标
	 */
	private Integer index;

	/**
	 * 干支
	 */
	private String ganZhi;

	/**
	 * 根据地支获取天干
	 *
	 * @param zhi
	 * @return
	 */
	public String getGanByZhi(String zhi) {
		if (ganZhi.contains(zhi)) {
			return String.valueOf(ganZhi.charAt(0));
		}
		return "";
	}

	/**
	 * 通过旬的下标获取旬中所有的甲子
	 *
	 * @param index
	 * @return
	 */
	public static List<JiaZiXunEnum> getGanZhiByXunIndex(Integer index) {
		List<JiaZiXunEnum> result = new ArrayList<>(10);
		JiaZiXunEnum[] values = JiaZiXunEnum.values();
		for (JiaZiXunEnum value : values) {
			if (value.index.equals(index)) {
				result.add(value);
			}
		}
		return result;
	}

	JiaZiXunEnum(Integer index, String ganZhi) {
		this.index = index;
		this.ganZhi = ganZhi;
	}
}
